
class Model{
    constructor(ModelConfig){
        this.name = ModelConfig.objName;
        this.position = ModelConfig.objPosition;
        this.resourceID = ModelConfig.resourceID;
        this.modelName = ModelConfig.modelName;
        this.modelType = ModelConfig.modelType;
        this.cabinet = ModelConfig.cabinet;
        this.detailType = ModelConfig.detailType;
        this.rotation = ModelConfig.rotationObject;
        this.description = ModelConfig.description;
        this.orientation = ModelConfig.orientation;
        this.room = ModelConfig.room;
        this.area = ModelConfig.area;
        this.block = ModelConfig.block
    }
    getName(){
        return this.name
    }
    getResourceID(){
        return this.resourceID
    }
    getModelName(){
        return this.modelName
    }
    getCabinet(){
        return this.cabinet
    }
}

class Cabinet extends Model{
    constructor(ModelConfig,model,textLabel,transparent,isTransparentSet) {
        super(ModelConfig);
        this.model = model;
        this.textLabel = textLabel;
        this.transparent = transparent;
        this.isTransparentSet = isTransparentSet;
    }
    getName(){
        return this.name
    }
    getResourceID(){
        return this.resourceID
    }
    getModelName(){
        return this.modelName
    }
}

class Cabinet extends Model{
    constructor(ModelConfig,model,textLabel,transparent,isTransparentSet) {
        super(ModelConfig);
        this.model = model;
        this.textLabel = textLabel;
        this.transparent = transparent;
        this.isTransparentSet = isTransparentSet;
    }
    getName(){
        return this.name
    }
    getResourceID(){
        return this.resourceID
    }
    getModelName(){
        return this.modelName
    }
}


function loadModel(device,path,callback){
    var objLoader=new THREE.OBJLoader();
    objLoader.setPath( path );
    var mtllLoader=new THREE.MTLLoader();
    mtllLoader.setPath( path );
    mtllLoader.load( device.modelName+'.mtl', function ( materials ) {
        materials.preload();
        objLoader.setMaterials( materials ).load( device.modelName+'.obj', function ( object ) {
            object.position.set(device.position.x,device.position.y,device.position.z) ;
            object.rotation.set(device.rotation.x,device.rotation.y,device.rotation.z);
            device.model=object;
            scene.add( object );
            object.name=device.name;
            if(callback!=null){
                callback(object,device);
            }
            object.scale.set(object.scale.x*allScale,object.scale.y*allScale,object.scale.z*allScale);
            initBlocks(device);
        }, onProgress, onError );
    } );
}